package com.xidian.zhiancloud.controller.ledgerManagerment.targetAndSystem;

import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.SecurityInputLedgerDetail;
import com.xidian.zhiancloud.service.ledgerManager.targerAndSystem.SecurityInputLedgerDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 台账管理 目标职责与制度 安全投入台账细节
 *
 * @Author: Summerless
 * @Date: 2020/11/9 11:30
 */
@RestController
@RequestMapping("/SecurityInputLedgerDetail")
public class SecurityInputLedgerDetailController {
    @Autowired
    private SecurityInputLedgerDetailService securityInputLedgerDetailService;

    /**
     * 根据id列表删除安全投入台账细节对象
     *
     * @param ids 安全投入台账细节对象的id
     * @return 是否删除成功
     */
    @DeleteMapping("/deleteByIds")
    public ResultDTO<Boolean> deleteByIds(Long[] ids) {
        securityInputLedgerDetailService.removeByIds(Arrays.asList(ids));
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    /**
     * 修改安全投入台账细节对象
     *
     * @param securityInputLedgerDetail 安全投入台账细节对象
     * @return 是否修改成功
     */
    @PatchMapping("/patchById")
    public ResultDTO<Boolean> patchById(SecurityInputLedgerDetail securityInputLedgerDetail) {
        securityInputLedgerDetailService.updateById(securityInputLedgerDetail);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }
}
